/**
 *			\author ITII - ISEN - P6
 *			\author Benjamin Mur
 *			\file SmtpServer.h
 *			\version 0.2
 *			\date 10/09/2010
 */

#ifndef SMTPSERVER_H_INCLUDED
#define SMTPSERVER_H_INCLUDED

#include "TcpServer.h"
#include "Mail.h"

class SmtpServer
{

    private:
                TcpServer *	_tcpServ;
                char *		_buffer;
                int		_bufferSize;
                Mail		_mail;
                bool		_init;
                bool		_fillOut;
                std::string	_data;

		std::string	extractMailAddress(const char * buffer);
                int		receiveCommand(char * buffer);
                int		process( char * buffer, int & step );
                char *		extractCommand( char * texte, int car, int occurence);
	public:
                                SmtpServer(int port = 25);
				~SmtpServer();

                Mail            receiveMail();
                bool		isInit() const;
                bool		isFillOut() const;
};

#endif // SMTPSERVER_H_INCLUDED
